﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Crgd.UAuthServer.Core.Extensions
{
    public static class IServiceProviderExtension
    {
        public static async Task RunInNewScopeAsync(this IServiceProvider provider, Func<IServiceProvider, Task> task)
        {
            using (var scope = provider.CreateScope())
            {
                await task(scope.ServiceProvider);
            }
        }
    }
}
